package wisecashier

import (
	//"wxsdk/utils/mapstruct"
	"github.com/astaxie/beego"
)

type RefundData struct {
	RefundInfo struct {
		No            string `json:"no"`
		OrderNo       string `json:"order_no"`
		OuterRefundNo string `json:"outer_refund_no"`
		RefundAmount  string `json:"refund_amount"`
		Status        string `json:"status"`
	} `json:"refund"`
}

type RefundsResponse struct {
	RspHeader  RspHeader  `json:"meta,omitempty"`
	RefundData RefundData `json:"data,omitempty"`
}

func Refunds(merchanNo,orderNo,orderId,refundAmount,privateKey string)(rsp *RefundsResponse, err error){
	var reqParams map[string]interface{}
	rsp = new(RefundsResponse)
	reqParams = make(map[string]interface{})
	reqParams["order_no"] = orderNo
	reqParams["refund_amount"] = refundAmount
	reqParams["outer_refund_no"] = orderId
	reqURL := "https://api.wisecashier.com/refund"
	sdk := NewSDK(reqURL, merchanNo, []byte(privateKey))
	_, err = sdk.Execute(reqParams, rsp)
	if err != nil {
		beego.Debug("WiseCashier Refunds err:", err.Error())
		return
	}
	return
}

